Skip to content

tests: assert histogram/exp_histogram temporality survives in_opentelemetry -> out_opentelemetry round trip#12042

Open
truongnht wants to merge 1 commit into
fluent:masterfrom
truongnht:fix/histogram-temporality-msgpack
Open

tests: assert histogram/exp_histogram temporality survives in_opentelemetry -> out_opentelemetry round trip#12042
truongnht wants to merge 1 commit into
fluent:masterfrom
truongnht:fix/histogram-temporality-msgpack

Conversation

@truongnht

@truongnht truongnht commented Jul 3, 2026

Copy link
Copy Markdown

Summary

The actual fix (fluent/cmetrics#279) is already included via the lib: cmetrics: upgrade to v2.2.0 bump merged into master. This PR is now just the missing test coverage.

tests/integration/scenarios/in_opentelemetry/tests/test_in_opentelemetry_001.py::test_opentelemetry_to_opentelemetry_histogram_and_gauge_metrics already sends a histogram with aggregation_temporality: 1 (DELTA) through a real in_opentelemetry → out_opentelemetry pipeline (test_metrics_002.in.json), but never asserted on the output's aggregationTemporality field. That gap is exactly how the cmetrics bug — histograms/exp_histograms losing their OTLP temporality across Fluent Bit's internal msgpack buffer — went unnoticed. This adds the missing assertion so a regression here is caught going forward.

Background

Original bug: pack_header() in cmetrics' cmt_encode_msgpack.c only wrote the aggregation_type meta field for CMT_COUNTER. Histograms and exp_histograms decoded from OTLP by in_opentelemetry, buffered internally as msgpack, and re-encoded to OTLP by out_opentelemetry lost their temporality in that round trip. Downstream OTLP receivers that validate temporality (e.g. Prometheus with otlp-deltatocumulative enabled) rejected the metric with invalid temporality and type combination. Filed as #278, fixed in fluent/cmetrics#279.

Test plan

  • Built Fluent Bit with lib/cmetrics reverted to pre-v2.2.0 (unpatched): confirmed test_opentelemetry_to_opentelemetry_histogram_and_gauge_metrics fails — the response's histogram has no aggregationTemporality field at all (proto JSON omits UNSPECIFIED)
  • Built Fluent Bit with lib/cmetrics at v2.2.0 (patched): confirmed the same test passes, with aggregationTemporality: AGGREGATION_TEMPORALITY_DELTA correctly present in the OTLP output
  • Ran the full in_opentelemetry integration suite (62 tests) — all pass, no regressions
  • Ran the full out_opentelemetry integration suite (17 tests) — all pass, no regressions
  • Also reproduced end-to-end against a real cluster: ran a k6 OTLP load test through in_opentelemetry → out_opentelemetry → Prometheus with the unpatched image (k6's histogram metrics rejected by Prometheus) and again with a patched image (same metrics landed correctly, confirmed via direct Prometheus API query)

Summary by CodeRabbit

  • Tests
    • Added validation that histogram aggregation temporality remains unchanged during the OpenTelemetry round trip.
    • Confirmed delta temporality is correctly decoded and re-encoded.

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The OpenTelemetry integration test now verifies that histogram aggregation temporality remains AGGREGATION_TEMPORALITY_DELTA through the Fluent Bit round trip.

Changes

Histogram temporality validation

Layer / File(s) Summary
Validate histogram temporality
tests/integration/scenarios/in_opentelemetry/tests/test_in_opentelemetry_001.py
Adds an assertion covering histogram temporality after decoding, encoding, and the internal msgpack round trip.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Suggested reviewers: cosmo0920

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the added regression test for histogram temporality surviving the OpenTelemetry round trip.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@truongnht

truongnht commented Jul 3, 2026

Copy link
Copy Markdown
Author

before the fix

image

patch fluent-operator with the fix image

image

…emetry -> out_opentelemetry round trip

The fix itself (fluent/cmetrics#279) is already included via the
lib: cmetrics: upgrade to v2.2.0 bump on master.

tests/integration/scenarios/in_opentelemetry/tests/test_in_opentelemetry_001.py::test_opentelemetry_to_opentelemetry_histogram_and_gauge_metrics
already sends a histogram with aggregation_temporality=1 (DELTA) through
a real in_opentelemetry -> out_opentelemetry pipeline
(test_metrics_002.in.json), but never asserted on the output's
aggregationTemporality field. That gap is exactly how the cmetrics bug
(histograms/exp_histograms losing their OTLP temporality across Fluent
Bit's internal msgpack buffer) went unnoticed. Adds the missing
assertion so a regression here is caught going forward.

Verified locally against both sides of the cmetrics fix:
- Built Fluent Bit with lib/cmetrics reverted to pre-v2.2.0 (unpatched):
  this test fails - the response's histogram has no aggregationTemporality
  field at all, since UNSPECIFIED is omitted by proto JSON serialization.
- Built Fluent Bit with lib/cmetrics at v2.2.0 (patched): this test passes,
  with aggregationTemporality: AGGREGATION_TEMPORALITY_DELTA correctly
  present in the OTLP output.
- Full in_opentelemetry (62 tests) and out_opentelemetry (17 tests) suites
  pass with no regressions.

Also reproduced end-to-end against a real cluster: ran a k6 OTLP load
test through in_opentelemetry -> out_opentelemetry -> Prometheus with the
unpatched image (k6's histogram metrics were rejected by Prometheus with
"invalid temporality and type combination") and again with a patched
image (same metrics landed correctly, confirmed via direct Prometheus API
query).

Signed-off-by: Truong Nguyen <truong.nguyen_1@philips.com>
@truongnht truongnht force-pushed the fix/histogram-temporality-msgpack branch from f0eb9d9 to a7835d8 Compare July 10, 2026 21:31
@truongnht truongnht changed the title fix: preserve histogram/exp_histogram temporality across internal msgpack round-trip tests: assert histogram/exp_histogram temporality survives in_opentelemetry -> out_opentelemetry round trip Jul 10, 2026
@truongnht

Copy link
Copy Markdown
Author

Rebased onto master — the cmetrics fix landed via the lib: cmetrics: upgrade to v2.2.0 bump (3ceed7d), so this PR now only adds the missing test assertion that would have caught the regression. Updated title/description accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant